<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	pageContext.setAttribute("basePath",request.getContextPath());
%>
<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>茶种编辑</title>
	<link rel="shortcut icon" href="favicon.ico">
	<link href="${basePath }/static/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/font-awesome.min.css" rel="stylesheet"/>
	<!-- bootstrap-table 表格插件样式 -->
	<link href="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/animate.css" rel="stylesheet"/>
	<link href="${basePath }/static/css/style.css" rel="stylesheet"/>
	<link href="${basePath }/static/ruoyi/css/ry-ui.css" rel="stylesheet"/>
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m-t" id="editForm">
		<input type="hidden" name="teaId" value="${teaCategory.teaId }" />
		<div class="form-group">
             <label for="recipient-name" class="control-label">茶叶名称：</label>
             <input type="text" class="form-control" id="recipient-name" required pattern="[\u4e00-\u9fa5]+" name="teaName" value="${teaCategory.teaName }" />
         </div>
         <div class="form-group">
             <label for="message-text" class="control-label">季节分类：</label>
             <input class="form-control" id="message-season" required pattern="[\u4e00-\u9fa5]+" name="teaSeason" value="${teaCategory.teaSeason }"/>
         </div>
         <div class="form-group">
             <label for="message-text" class="control-label">茶系：</label>
             <select class="form-control" name="teaClass">
             	 <option value="${teaCategory.teaClass }">${teaCategory.teaClass }</option>
                 <option value="绿茶">绿茶</option>
                 <option value="白茶">白茶</option>
                 <option value="黄茶">黄茶</option>
                 <option value="黑茶">黑茶</option>
                 <option value="青茶">青茶</option>
                 <option value="红茶">红茶</option>
             </select>
         </div>
         <div class="form-group">
             <label for="message-text" class="control-label">鲜叶叶型：</label>
             <input class="form-control" id="message-text" required pattern="[\u4e00-\u9fa5]+" name="leavesType" value="${teaCategory.leavesType }"/>
         </div>
         <div class="form-group">
             <label for="message-text" class="control-label">鲜叶品种：</label>
             <input class="form-control" id="message-varieties" required pattern="[\u4e00-\u9fa5]+" name="leavesVarieties" value="${teaCategory.leavesVarieties }" />
         </div>
        <!--  <div class="modal-footer">
             <button type="button" class="btn btn-primary btn_save">保存</button>
         </div> -->
	</form>
    </div>
    
	<script src="${basePath }/static/js/jquery.min.js"></script>
	<script src="${basePath }/static/js/bootstrap.min.js"></script>
	<!-- bootstrap-table 表格插件 -->
	<script src="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${basePath }/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
	<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
	<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js"></script>
	<!-- jquery-validate 表单验证插件 -->
	<script src="${basePath }/static/ajax/libs/validate/jquery.validate.min.js"></script>
	<script src="${basePath }/static/ajax/libs/validate/messages_zh.min.js"></script>
	<script src="${basePath }/static/ajax/libs/validate/jquery.validate.extend.js"></script>
	<!-- jquery-validate 表单树插件 -->
	<script src="${basePath }/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
	<!-- jquery-export 表格导出插件 -->
	<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
	<script src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
	
	<script src="${basePath }/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
	
	<!-- 遮罩层 -->
	<script src="${basePath }/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
	   <script src="${basePath }/static/ajax/libs/iCheck/icheck.min.js"></script>
	<script src="${basePath }/static/ajax/libs/layer/layer.min.js"></script>
	<script src="${basePath }/static/ajax/libs/layui/layui.js"></script>
	<script src="${basePath }/static/ruoyi/js/common.js"></script>
	<script src="${basePath }/static/ruoyi/js/ry-ui.js"></script>
	<script src="${basePath }/assets/js/tree.js"></script>

	
	<script>
		/* $(".btn_save").click(function() {
			$.ajax({
	        	url : "editTeaCategory.do",
	        	type : "POST",
	        	dataType : "json",
	        	data: $("#editForm").serialize(),
	            success : function (response) {
	            	layer.closeAll('iframe');//关闭弹窗
	            }                	  
	        });
		}); */
		
		//获取项目根目录
		function getRootPath(){
			let href = window.document.location.href;
			let pathName = window.document.location.pathname;
			let index = href.indexOf(pathName);
			let localhost = href.substring(0,index);
			let project = pathName.substring(0,(pathName.substr(1).indexOf('/'))+1);
				
			return (localhost+project);
		}
		
		let rootPath = getRootPath();
		
	   /* $(function() {
		    var roleId = $("input[name='roleId']").val();
			var url = rootPath + "/system/menu/roleTree.do?roleId="+roleId;
			var options = {
				id: "menuTrees",
		        url: url,
		        check: { enable: true },
		        expandLevel: 0
		    };
			$.ztree.init(options);
		}); */
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	role_edit();
	        }
	    }

		function role_edit() {
			/* 
			var teaId = $("input[name='teaId']").val();
			var teaName = $("input[name='teaName']").val();
			var teaSeason = $("input[name='teaSeason']").val();
			var teaClass = $("input[name='teaClass']").val();
			var leavesType = $("input[name='leavesType']").val();
			var leavesVarieties = $("input[name='leavesVarieties']").val();
			
			console.log($("#editForm").serialize());
			return;
			
			if($.common.isEmpty(menuIds)){
				$.modal.alert("菜单权限不能为空");
				return;
			} */
			
			$.ajax({
				type : "POST",
				url : "editTeaCategory.do",
				data : $("#editForm").serialize(),
				dataType: "json",
				success:function(response){
					
					if(response.RESULT == "failed"){
						$.modal.alert("保存失败,"+response.message);
						return;
					}
					
					var parent = window.parent;
	                if (parent.$.table._option.type == table_type.bootstrapTable) {
	                    $.modal.close();
	                    parent.$.modal.msgSuccess(response.message);
	                    parent.$.table.refresh();
	                } else if (parent.$.table._option.type == table_type.bootstrapTreeTable) {
	                    $.modal.close();
	                    parent.$.modal.msgSuccess(response.message);
	                    parent.$.treeTable.refresh();
	                } else {
	                    $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
	                }
				}
			});
		}
		
	</script>
	
</body>
</html>